persfreedomagency: Pillar of Personal Freedom –> the degree to which citizens are free from restriction and are free to move, indicating the experiences of the freedom to act independently and making free choices
Socialcapsocialnetwork: Social network (pillar of Social capital)
Healthprevent: Preventative interventions (pillar of Health)
Socialcapcivic: Civic and social participation (pillar of Social capital)
PersonalFreedom: Freedom of assembly and association (pillar of Personal Freedom)
GovernanGovernmeffect: Government effectiveness (pillar of Governance)
Socialcappersonalandfamily: Personal and family relationships (pillar of Social capital)
| location | stringency_class | excess_death_class | persfreedomagency | Socialcapsocialnetwork | healthprevent | Socialcapcivic | PersonalFreedom | GovernanGovernmeffect | Socialcappersonalandfamily | continent | population | population_density | median_age | aged_65_older | gdp_per_capita | life_expectancy | Climateclass | cum_p_score | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 64 | Switzerland | 2 | 1 | 22.4 | 15.4 | 13.8 | 10.7 | 18.8 | 19.1 | 17.1 | Europe | 8715494 | 214.243 | 43.1 | 18.436 | 57410.17 | 83.78 | Class C - Temperate (Mesothermal) Climates | 0.0772404 |
| 3 | Austria | 2 | 1 | 22.1 | 14.6 | 13.2 | 12.2 | 17.7 | 17.9 | 16.2 | Europe | 9043072 | 106.749 | 44.4 | 19.202 | 45436.69 | 81.54 | Class C - Temperate (Mesothermal) Climates | 0.0845804 |
| location | stringency_class | excess_death_class | persfreedomagency | Socialcapsocialnetwork | healthprevent | Socialcapcivic | PersonalFreedom | GovernanGovernmeffect | Socialcappersonalandfamily | continent | population | population_density | median_age | aged_65_older | gdp_per_capita | life_expectancy | Climateclass | cum_p_score | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 18 | Egypt | 1 | 4 | 8.7 | 14.9 | 12.5 | 0.8 | 2.1 | 7.3 | 9.9 | Africa | 104258327 | 97.999 | 25.3 | 5.159 | 10550.21 | 71.99 | Class B - Dry (Arid and Semiarid) Climates | 0.1983465 |
| 16 | Denmark | 2 | 3 | 22.9 | 16.0 | 13.8 | 11.7 | 19.5 | 18.6 | 18.3 | Europe | 5813302 | 136.520 | 42.3 | 19.677 | 46682.51 | 80.90 | Class C - Temperate (Mesothermal) Climates | 0.0071318 |
Pick number of clusters using the silhouette figure
2 clusters has the highest silhouette width. 3 is simpler and almost as good. Let’s pick k = 3
## [[1]]
## location stringency_class excess_death_class persfreedomagency
## Length:20 1:10 1:17 Min. : 9.40
## Class :character 2: 4 2: 1 1st Qu.:14.70
## Mode :character 3: 5 3: 2 Median :16.40
## 4: 1 4: 0 Mean :16.23
## 3rd Qu.:18.07
## Max. :20.90
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## Min. : 8.50 Min. : 9.20 Min. : 4.100 Min. : 5.40
## 1st Qu.:12.20 1st Qu.:11.75 1st Qu.: 4.575 1st Qu.:12.38
## Median :13.00 Median :12.65 Median : 5.650 Median :13.45
## Mean :12.92 Mean :12.33 Mean : 5.945 Mean :13.84
## 3rd Qu.:13.82 3rd Qu.:13.20 3rd Qu.: 6.825 3rd Qu.:16.07
## Max. :15.80 Max. :14.00 Max. :10.100 Max. :18.30
## GovernanGovernmeffect Socialcappersonalandfamily continent
## Min. : 5.900 Min. :10.60 Africa : 1
## 1st Qu.: 9.525 1st Qu.:14.65 Asia : 4
## Median :11.450 Median :15.60 Europe :14
## Mean :11.210 Mean :15.06 North America: 0
## 3rd Qu.:13.200 3rd Qu.:16.12 Oceania : 0
## Max. :16.000 Max. :17.30 South America: 1
## population population_density median_age aged_65_older
## Min. : 98910 Min. : 8.823 Min. :26.30 Min. : 4.489
## 1st Qu.: 3165828 1st Qu.: 56.857 1st Qu.:37.52 1st Qu.:13.359
## Median : 5355002 Median : 78.841 Median :41.30 Median :15.663
## Mean : 18015135 Mean :127.877 Mean :39.62 Mean :15.000
## 3rd Qu.: 12007564 3rd Qu.:123.748 3rd Qu.:43.10 3rd Qu.:18.032
## Max. :145912022 Max. :594.561 Max. :44.70 Max. :20.801
## gdp_per_capita life_expectancy
## Min. : 3393 Min. :71.45
## 1st Qu.:11781 1st Qu.:73.68
## Median :21611 Median :76.47
## Mean :19515 Mean :76.36
## 3rd Qu.:26481 3rd Qu.:78.61
## Max. :35938 Max. :83.03
## Climateclass cum_p_score
## : 0 Min. :-0.06918
## Class A - Tropical Climates : 1 1st Qu.: 0.10505
## Class B - Dry (Arid and Semiarid) Climates : 0 Median : 0.16355
## Class C - Temperate (Mesothermal) Climates :16 Mean : 0.14279
## Class D - Continental (Microthermal) Climates: 3 3rd Qu.: 0.20348
## Max. : 0.25187
## cluster
## Min. :1
## 1st Qu.:1
## Median :1
## Mean :1
## 3rd Qu.:1
## Max. :1
##
## [[2]]
## location stringency_class excess_death_class persfreedomagency
## Length:28 1: 5 1:10 Min. :15.00
## Class :character 2:14 2: 1 1st Qu.:20.02
## Mode :character 3: 6 3:10 Median :21.10
## 4: 3 4: 7 Mean :20.86
## 3rd Qu.:21.95
## Max. :23.80
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## Min. : 5.10 Min. :12.60 Min. : 4.100 Min. :12.00
## 1st Qu.:13.45 1st Qu.:13.20 1st Qu.: 6.675 1st Qu.:17.30
## Median :14.65 Median :13.60 Median : 9.450 Median :17.95
## Mean :13.98 Mean :13.51 Mean : 9.357 Mean :17.65
## 3rd Qu.:15.70 3rd Qu.:13.82 3rd Qu.:12.200 3rd Qu.:18.43
## Max. :16.40 Max. :14.10 Max. :14.000 Max. :19.50
## GovernanGovernmeffect Socialcappersonalandfamily continent
## Min. :12.10 Min. :12.10 Africa : 0
## 1st Qu.:17.68 1st Qu.:15.78 Asia : 3
## Median :18.20 Median :16.20 Europe :22
## Mean :17.44 Mean :16.18 North America: 1
## 3rd Qu.:18.73 3rd Qu.:17.10 Oceania : 2
## Max. :19.10 Max. :18.30 South America: 0
## population population_density median_age aged_65_older
## Min. : 368792 Min. : 3.202 Min. :30.60 Min. :11.73
## 1st Qu.: 5368528 1st Qu.: 42.753 1st Qu.:39.70 1st Qu.:15.48
## Median : 9167036 Median : 112.750 Median :42.60 Median :18.89
## Mean : 31695700 Mean : 443.128 Mean :42.10 Mean :18.31
## 3rd Qu.: 19326875 3rd Qu.: 245.987 3rd Qu.:44.58 3rd Qu.:19.75
## Max. :332915074 Max. :7039.714 Max. :48.20 Max. :27.05
## gdp_per_capita life_expectancy
## Min. :24574 Min. :75.93
## 1st Qu.:33987 1st Qu.:81.33
## Median :41622 Median :82.27
## Mean :43980 Mean :81.88
## 3rd Qu.:47330 3rd Qu.:82.97
## Max. :94278 Max. :84.86
## Climateclass cum_p_score
## : 0 Min. :-0.04109
## Class A - Tropical Climates : 1 1st Qu.: 0.02111
## Class B - Dry (Arid and Semiarid) Climates : 1 Median : 0.07470
## Class C - Temperate (Mesothermal) Climates :22 Mean : 0.06771
## Class D - Continental (Microthermal) Climates: 4 3rd Qu.: 0.10185
## Max. : 0.18554
## cluster
## Min. :2
## 1st Qu.:2
## Median :2
## Mean :2
## 3rd Qu.:2
## Max. :2
##
## [[3]]
## location stringency_class excess_death_class persfreedomagency
## Length:22 1:12 1: 0 Min. : 5.70
## Class :character 2: 2 2:14 1st Qu.:12.25
## Mode :character 3: 7 3: 4 Median :15.25
## 4: 1 4: 4 Mean :14.02
## 3rd Qu.:15.88
## Max. :20.00
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## Min. :10.10 Min. : 9.80 Min. : 0.800 Min. : 1.700
## 1st Qu.:14.00 1st Qu.:12.05 1st Qu.: 4.275 1st Qu.: 3.775
## Median :15.00 Median :13.45 Median : 6.150 Median :12.400
## Mean :14.55 Mean :12.84 Mean : 6.027 Mean :10.041
## 3rd Qu.:15.50 3rd Qu.:13.70 3rd Qu.: 8.200 3rd Qu.:14.675
## Max. :16.30 Max. :14.40 Max. :10.700 Max. :17.500
## GovernanGovernmeffect Socialcappersonalandfamily continent
## Min. : 5.200 Min. : 9.70 Africa :3
## 1st Qu.: 8.475 1st Qu.:14.50 Asia :9
## Median : 9.900 Median :15.80 Europe :0
## Mean :10.105 Mean :15.16 North America:3
## 3rd Qu.:11.825 3rd Qu.:16.50 Oceania :0
## Max. :15.000 Max. :18.00 South America:7
## population population_density median_age aged_65_older
## Min. : 1273428 Min. : 1.98 Min. :22.90 Min. : 1.307
## 1st Qu.: 5895110 1st Qu.: 24.47 1st Qu.:28.12 1st Qu.: 5.205
## Median : 18622413 Median : 58.14 Median :30.65 Median : 6.780
## Mean : 41321248 Mean : 447.64 Mean :31.06 Mean : 6.909
## 3rd Qu.: 57847957 3rd Qu.: 113.98 3rd Qu.:33.23 3rd Qu.: 8.325
## Max. :213993441 Max. :7915.73 Max. :42.40 Max. :12.922
## gdp_per_capita life_expectancy
## Min. : 6253 Min. :64.13
## 1st Qu.: 10897 1st Qu.:73.15
## Median : 14814 Median :75.47
## Mean : 22994 Mean :75.33
## 3rd Qu.: 19990 3rd Qu.:77.25
## Max. :116936 Max. :83.62
## Climateclass cum_p_score
## : 0 Min. :0.02013
## Class A - Tropical Climates :10 1st Qu.:0.11462
## Class B - Dry (Arid and Semiarid) Climates : 9 Median :0.19834
## Class C - Temperate (Mesothermal) Climates : 1 Mean :0.19346
## Class D - Continental (Microthermal) Climates: 2 3rd Qu.:0.24568
## Max. :0.45778
## cluster
## Min. :3
## 1st Qu.:3
## Median :3
## Mean :3
## 3rd Qu.:3
## Max. :3
## location stringency_class excess_death_class persfreedomagency
## Length:70 1:27 1:27 Min. : 5.70
## Class :character 2:20 2:16 1st Qu.:15.22
## Mode :character 3:18 3:16 Median :17.60
## 4: 5 4:11 Mean :17.39
## 3rd Qu.:20.88
## Max. :23.80
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## Min. : 5.10 Min. : 9.20 Min. : 0.800 Min. : 1.70
## 1st Qu.:12.88 1st Qu.:12.53 1st Qu.: 4.925 1st Qu.:12.40
## Median :14.40 Median :13.30 Median : 6.850 Median :16.00
## Mean :13.86 Mean :12.96 Mean : 7.336 Mean :14.17
## 3rd Qu.:15.40 3rd Qu.:13.78 3rd Qu.: 9.100 3rd Qu.:17.70
## Max. :16.40 Max. :14.40 Max. :14.000 Max. :19.50
## GovernanGovernmeffect Socialcappersonalandfamily continent
## Min. : 5.20 Min. : 9.70 Africa : 4
## 1st Qu.: 9.95 1st Qu.:14.93 Asia :16
## Median :12.85 Median :16.00 Europe :36
## Mean :13.35 Mean :15.54 North America: 4
## 3rd Qu.:17.90 3rd Qu.:16.50 Oceania : 2
## Max. :19.10 Max. :18.30 South America: 8
## population population_density median_age aged_65_older
## Min. : 98910 Min. : 1.98 Min. :22.90 Min. : 1.307
## 1st Qu.: 4306969 1st Qu.: 31.49 1st Qu.:32.40 1st Qu.: 8.524
## Median : 9167036 Median : 84.30 Median :39.65 Median :14.759
## Mean : 30812139 Mean : 354.48 Mean :37.92 Mean :13.780
## 3rd Qu.: 33791678 3rd Qu.: 152.67 3rd Qu.:43.08 3rd Qu.:18.946
## Max. :332915074 Max. :7915.73 Max. :48.20 Max. :27.049
## gdp_per_capita life_expectancy
## Min. : 3393 Min. :64.13
## 1st Qu.: 14063 1st Qu.:75.11
## Median : 26580 Median :78.65
## Mean : 30394 Mean :78.24
## 3rd Qu.: 39565 3rd Qu.:82.19
## Max. :116936 Max. :84.86
## Climateclass cum_p_score
## : 0 Min. :-0.06918
## Class A - Tropical Climates :12 1st Qu.: 0.05075
## Class B - Dry (Arid and Semiarid) Climates :10 Median : 0.11256
## Class C - Temperate (Mesothermal) Climates :39 Mean : 0.12868
## Class D - Continental (Microthermal) Climates: 9 3rd Qu.: 0.19609
## Max. : 0.45778
## cluster
## Min. :1.000
## 1st Qu.:1.000
## Median :2.000
## Mean :2.029
## 3rd Qu.:3.000
## Max. :3.000
| location | excess_death_class | stringency_class | Climateclass |
|---|---|---|---|
| Albania | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Bosnia and Herzegovina | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Bulgaria | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Croatia | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Estonia | 1 | 1 | Class D - Continental (Microthermal) Climates |
| Georgia | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Hungary | 1 | 3 | Class C - Temperate (Mesothermal) Climates |
| Kyrgyzstan | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Latvia | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Lebanon | 1 | 3 | Class C - Temperate (Mesothermal) Climates |
| Moldova | 1 | 3 | Class C - Temperate (Mesothermal) Climates |
| Poland | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Russia | 1 | 1 | Class D - Continental (Microthermal) Climates |
| Serbia | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Seychelles | 1 | 4 | Class A - Tropical Climates |
| Ukraine | 1 | 1 | Class D - Continental (Microthermal) Climates |
| Uruguay | 1 | 3 | Class C - Temperate (Mesothermal) Climates |
| Romania | 2 | 2 | Class C - Temperate (Mesothermal) Climates |
| Cyprus | 3 | 1 | Class C - Temperate (Mesothermal) Climates |
| South Korea | 3 | 3 | Class C - Temperate (Mesothermal) Climates |
|
|
|
|
58% (11/19 countries) in Excess Death Class 4 (e.g. Russia, Hungary, Ukraine)
63% (12/19 countries) in Stringency Class 1
68% (13/19 countries) in Temperate (Mesothermal) Climates
| location | excess_death_class | stringency_class | Climateclass |
|---|---|---|---|
| Austria | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Czechia | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Israel | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Lithuania | 1 | 2 | Class D - Continental (Microthermal) Climates |
| Luxembourg | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Malta | 1 | 1 | Class C - Temperate (Mesothermal) Climates |
| Slovakia | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Slovenia | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| Switzerland | 1 | 2 | Class C - Temperate (Mesothermal) Climates |
| United States | 1 | 3 | Class C - Temperate (Mesothermal) Climates |
| Portugal | 2 | 3 | Class C - Temperate (Mesothermal) Climates |
| Australia | 3 | 2 | Class B - Dry (Arid and Semiarid) Climates |
| Denmark | 3 | 2 | Class C - Temperate (Mesothermal) Climates |
| Finland | 3 | 1 | Class D - Continental (Microthermal) Climates |
| Germany | 3 | 4 | Class C - Temperate (Mesothermal) Climates |
| Greece | 3 | 4 | Class C - Temperate (Mesothermal) Climates |
| Hong Kong | 3 | 2 | Class A - Tropical Climates |
| Iceland | 3 | 2 | Class C - Temperate (Mesothermal) Climates |
| Japan | 3 | 4 | Class C - Temperate (Mesothermal) Climates |
| New Zealand | 3 | 1 | Class C - Temperate (Mesothermal) Climates |
| Norway | 3 | 3 | Class D - Continental (Microthermal) Climates |
| Belgium | 4 | 1 | Class C - Temperate (Mesothermal) Climates |
| Ireland | 4 | 2 | Class C - Temperate (Mesothermal) Climates |
| Italy | 4 | 2 | Class C - Temperate (Mesothermal) Climates |
| Netherlands | 4 | 2 | Class C - Temperate (Mesothermal) Climates |
| Spain | 4 | 3 | Class C - Temperate (Mesothermal) Climates |
| Sweden | 4 | 3 | Class D - Continental (Microthermal) Climates |
| United Kingdom | 4 | 3 | Class C - Temperate (Mesothermal) Climates |
Most in Excess Death Class 1 & 2 (e.g. Russia, Hungary, Ukraine)
48% in Stringency Class 3
85% (23/27 countries) in Temperate (Mesothermal) Climates
|
|
|
|
| location | excess_death_class | stringency_class | Climateclass |
|---|---|---|---|
| Azerbaijan | 2 | 3 | Class B - Dry (Arid and Semiarid) Climates |
| Brazil | 2 | 3 | Class A - Tropical Climates |
| Colombia | 2 | 3 | Class A - Tropical Climates |
| Costa Rica | 2 | 1 | Class A - Tropical Climates |
| Ecuador | 2 | 1 | Class A - Tropical Climates |
| Guatemala | 2 | 1 | Class A - Tropical Climates |
| Iran | 2 | 4 | Class B - Dry (Arid and Semiarid) Climates |
| Mexico | 2 | 3 | Class B - Dry (Arid and Semiarid) Climates |
| Oman | 2 | 3 | Class B - Dry (Arid and Semiarid) Climates |
| Paraguay | 2 | 1 | Class C - Temperate (Mesothermal) Climates |
| Peru | 2 | 1 | Class A - Tropical Climates |
| Qatar | 2 | 2 | Class B - Dry (Arid and Semiarid) Climates |
| South Africa | 2 | 1 | Class B - Dry (Arid and Semiarid) Climates |
| Uzbekistan | 2 | 1 | Class B - Dry (Arid and Semiarid) Climates |
| Mauritius | 3 | 2 | Class A - Tropical Climates |
| Mongolia | 3 | 3 | Class D - Continental (Microthermal) Climates |
| Singapore | 3 | 1 | Class A - Tropical Climates |
| Thailand | 3 | 1 | Class A - Tropical Climates |
| Bolivia | 4 | 1 | Class A - Tropical Climates |
| Chile | 4 | 3 | Class B - Dry (Arid and Semiarid) Climates |
| Egypt | 4 | 1 | Class B - Dry (Arid and Semiarid) Climates |
| Kazakhstan | 4 | 1 | Class D - Continental (Microthermal) Climates |
|
|
|
|
| Cluster 1 | Cluster 2 | Cluster 3 | |
|---|---|---|---|
| Number of Countries | 28 | 21 | 21 |
| Personal Freedom | 16.4 | 21.1 | 15.25 |
| Social Network | 13 | 14.65 | 15 |
| Assembly Freedom | 13.45 | 17.95 | 12.4 |
| Health Preventions | 12.65 | 13.6 | 13.45 |
| Social & Civic Participartion | 5.65 | 9.45 | 6.15 |
| Government Effect | 11.45 | 18.2 | 9.9 |
| Personal & Family Relationships | 15.6 | 16.2 | 15.8 |
| Population Density | 78.84 | 112.75 | 58.14 |
| Median Age | 41.3 | 42.6 | 30.65 |
| Aged 65 Older | 15.66 | 18.89 | 6.78 |
| GDP per capita | 21610.6 | 41622.15 | 14814.22 |
| Life Expectancy | 76.47 | 82.26 | 75.47 |
| Dominate Climate Class | Temperate (21) | Temperate (16) | Tropical (8) & Dry (8) |
| Excess Death Class | Class 1 (23) | Class 3 (12) & Class 4 (6) | Class 2 (14) |
| Stringency Class | Class 2 (14) | Class 1 (7) & Class 3 (6) | Class 1 (13) |
library(rsample)
data2$cluster <- relevel(as.factor(data2$cluster), ref = 2)
#data3 <- cbind(data2[c(2,3,17,18)], data2_mat[-1])
data_split <- initial_split(data2, prop = .75)
data_train <- training(data_split)[-1]
data_test <- testing(data_split)[-1]
library(nnet)
# Run a "only intercept" model
OIM <- multinom(cluster ~ 1, data = data_train)
## # weights: 6 (2 variable)
## initial value 57.127839
## final value 57.108728
## converged
summary(OIM)
## Call:
## multinom(formula = cluster ~ 1, data = data_train)
##
## Coefficients:
## (Intercept)
## 1 5.71584e-02
## 3 -8.54984e-09
##
## Std. Errors:
## (Intercept)
## 1 0.3381998
## 3 0.3429972
##
## Residual Deviance: 114.2175
## AIC: 118.2175
model <- multinom(cluster ~ ., data = data_train)
## # weights: 93 (60 variable)
## initial value 57.127839
## iter 10 value 34.726399
## iter 20 value 8.900943
## iter 30 value 5.284605
## iter 40 value 0.616017
## iter 50 value 0.131827
## iter 60 value 0.061905
## iter 70 value 0.024493
## iter 80 value 0.005463
## final value 0.000075
## converged
summary(model)
## Call:
## multinom(formula = cluster ~ ., data = data_train)
##
## Coefficients:
## (Intercept) stringency_class2 stringency_class3 stringency_class4
## 1 22.860238 -129.94600 1.058738 -209.86182
## 3 -4.224633 3.92066 -7.469922 -56.32008
## excess_death_class2 excess_death_class3 excess_death_class4 persfreedomagency
## 1 -29.37746 -131.29702 -54.680141 -2.493351
## 3 44.07459 50.33522 4.881733 136.374016
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## 1 75.66182 92.53841 18.468824 1.618292
## 3 169.31903 30.86458 6.449642 -131.393097
## GovernanGovernmeffect Socialcappersonalandfamily continentAsia
## 1 34.149578 -47.67178 -8.917245
## 3 1.526353 -43.78987 51.850091
## continentEurope continentNorth America continentOceania
## 1 11.74689 -34.90204 -1.842880
## 3 -36.57126 34.26249 -1.278195
## continentSouth America population population_density median_age
## 1 0.4570643 -4.818798e-07 1.1655735 3.065139
## 3 3.6549983 7.085976e-06 0.8644428 -129.304930
## aged_65_older gdp_per_capita life_expectancy
## 1 -30.76342 -0.06530090 3.142173
## 3 -137.71957 -0.02060771 55.873130
## ClimateclassClass A - Tropical Climates
## 1 -33.68206
## 3 31.26904
## ClimateclassClass B - Dry (Arid and Semiarid) Climates
## 1 -5.055084
## 3 13.188124
## ClimateclassClass C - Temperate (Mesothermal) Climates
## 1 39.77158
## 3 -29.47337
## ClimateclassClass D - Continental (Microthermal) Climates cum_p_score
## 1 21.82580 -13.277662
## 3 -19.20843 2.120371
##
## Std. Errors:
## (Intercept) stringency_class2 stringency_class3 stringency_class4
## 1 2.363847e-07 4.452977e-08 2.606673e-08 7.046433e-08
## 3 8.659380e-21 9.175819e-44 2.046525e-41 8.659380e-21
## excess_death_class2 excess_death_class3 excess_death_class4 persfreedomagency
## 1 4.452977e-08 7.046433e-08 2.606673e-08 4.532761e-06
## 3 4.133388e-114 9.175819e-44 2.046525e-41 1.376841e-19
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## 1 3.175240e-06 2.980414e-06 1.152044e-06 4.054232e-06
## 3 1.194994e-19 1.203654e-19 8.745973e-20 1.117060e-19
## GovernanGovernmeffect Socialcappersonalandfamily continentAsia
## 1 3.178366e-06 3.858797e-06 1.670647e-24
## 3 9.958287e-20 1.394160e-19 1.098913e-97
## continentEurope continentNorth America continentOceania
## 1 2.363847e-07 4.133388e-114 7.376054e-28
## 3 3.529905e-91 4.133388e-114 9.175819e-44
## continentSouth America population population_density median_age
## 1 2.046525e-41 6.707649e-06 7.135551e-06 1.033972e-05
## 3 2.046525e-41 8.564992e-16 1.804216e-18 3.134695e-19
## aged_65_older gdp_per_capita life_expectancy
## 1 4.617710e-06 6.080739e-03 1.867252e-05
## 3 7.452262e-20 2.284542e-16 6.355985e-19
## ClimateclassClass A - Tropical Climates
## 1 8.65938e-21
## 3 8.65938e-21
## ClimateclassClass B - Dry (Arid and Semiarid) Climates
## 1 2.046525e-41
## 3 2.055701e-41
## ClimateclassClass C - Temperate (Mesothermal) Climates
## 1 8.892737e-08
## 3 4.752105e-97
## ClimateclassClass D - Continental (Microthermal) Climates cum_p_score
## 1 1.474574e-07 2.456626e-08
## 3 3.529903e-91 5.990356e-22
##
## Residual Deviance: 0.0001499407
## AIC: 116.0001
## Model
## 1 1
## 2 stringency_class + excess_death_class + persfreedomagency + Socialcapsocialnetwork + healthprevent + Socialcapcivic + PersonalFreedom + GovernanGovernmeffect + Socialcappersonalandfamily + continent + population + population_density + median_age + aged_65_older + gdp_per_capita + life_expectancy + Climateclass + cum_p_score
## Resid. df Resid. Dev Test Df LR stat. Pr(Chi)
## 1 102 1.142175e+02 NA NA NA
## 2 46 1.499407e-04 1 vs 2 56 114.2173 7.220232e-06
# Calculate z-score for the model (wald Z)
zvalues <- summary(model)$coefficients / summary(model)$standard.errors
# Calculate p-values
#pnorm(abs(zvalues), lower.tail = FALSE)*2
# 2-tailed z test
p <- (1 - pnorm(abs(zvalues), 0, 1)) * 2
p
## (Intercept) stringency_class2 stringency_class3 stringency_class4
## 1 0 0 0 0
## 3 0 0 0 0
## excess_death_class2 excess_death_class3 excess_death_class4 persfreedomagency
## 1 0 0 0 0
## 3 0 0 0 0
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## 1 0 0 0 0
## 3 0 0 0 0
## GovernanGovernmeffect Socialcappersonalandfamily continentAsia
## 1 0 0 0
## 3 0 0 0
## continentEurope continentNorth America continentOceania
## 1 0 0 0
## 3 0 0 0
## continentSouth America population population_density median_age aged_65_older
## 1 0 0.942729 0 0 0
## 3 0 0.000000 0 0 0
## gdp_per_capita life_expectancy ClimateclassClass A - Tropical Climates
## 1 0 0 0
## 3 0 0 0
## ClimateclassClass B - Dry (Arid and Semiarid) Climates
## 1 0
## 3 0
## ClimateclassClass C - Temperate (Mesothermal) Climates
## 1 0
## 3 0
## ClimateclassClass D - Continental (Microthermal) Climates cum_p_score
## 1 0 0
## 3 0 0
# predicting values for train dataset
data_train$cluster_predicted <- predict(model, newdata = data_train, "class")
# building classification table
tab_train <- table(data_train$cluster, data_train$cluster_predicted)
# Calculating accuracy - sum of diagonal elements divided by total obs
round((sum(diag(tab_train))/sum(tab_train))*100,2)
## [1] 100
data_test$cluster_predicted <- predict(model, newdata = data_test, "class")
tab_test <- table(data_test$cluster, data_test$cluster_predicted)
round((sum(diag(tab_test))/sum(tab_test))*100,2)
## [1] 55.56
##
## Pearson's Chi-squared test
##
## data: data_test$cluster and data_test$cluster_predicted
## X-squared = 7.0948, df = 4, p-value = 0.131
## extract the coefficients from the model and exponentiate
exp(coef(model))
## (Intercept) stringency_class2 stringency_class3 stringency_class4
## 1 8.47374e+09 3.674249e-57 2.8827311489 7.213891e-92
## 3 1.46307e-02 5.043372e+01 0.0005699729 3.471380e-25
## excess_death_class2 excess_death_class3 excess_death_class4 persfreedomagency
## 1 1.743941e-13 9.515398e-58 1.789437e-24 8.263259e-02
## 3 1.384680e+19 7.249495e+21 1.318590e+02 1.684545e+59
## Socialcapsocialnetwork healthprevent Socialcapcivic PersonalFreedom
## 1 7.236178e+32 1.544967e+40 1.049321e+08 5.044468e+00
## 3 3.422304e+73 2.536985e+13 6.324756e+02 8.643764e-58
## GovernanGovernmeffect Socialcappersonalandfamily continentAsia
## 1 6.775999e+14 1.978825e-21 1.340571e-04
## 3 4.601367e+00 9.600688e-20 3.297680e+22
## continentEurope continentNorth America continentOceania
## 1 1.263602e+05 6.954010e-16 0.1583607
## 3 1.310103e-16 7.585944e+14 0.2785396
## continentSouth America population population_density median_age
## 1 1.57943 0.9999995 3.207762 2.143744e+01
## 3 38.66745 1.0000071 2.373683 6.975613e-57
## aged_65_older gdp_per_capita life_expectancy
## 1 4.361310e-14 0.9367855 2.315412e+01
## 3 1.545784e-60 0.9796032 1.842435e+24
## ClimateclassClass A - Tropical Climates
## 1 2.355418e-15
## 3 3.801658e+13
## ClimateclassClass B - Dry (Arid and Semiarid) Climates
## 1 6.376833e-03
## 3 5.339854e+05
## ClimateclassClass C - Temperate (Mesothermal) Climates
## 1 1.873178e+17
## 3 1.584454e-13
## ClimateclassClass D - Continental (Microthermal) Climates cum_p_score
## 1 3.011778e+09 1.712319e-06
## 3 4.548658e-09 8.334233e+00
## [1] 70